package com.grpc.server.service;

import org.example.grpc.lib.HelloReply;
import org.example.grpc.lib.HelloRequest;
import org.example.grpc.lib.SimpleGrpc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.grpc.stub.StreamObserver;
import net.devh.boot.grpc.server.service.GrpcService;

@GrpcService
public class GrpcServerService extends SimpleGrpc.SimpleImplBase {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(GrpcServerService.class);

    @Override
    public void sayHello(HelloRequest req, StreamObserver<HelloReply> responseObserver) {
    	String message = "Hello ========== " + req.getName();
    	LOGGER.info(message);
        HelloReply reply = HelloReply.newBuilder()
                .setMessage(message)
                .build();
        responseObserver.onNext(reply);
        responseObserver.onCompleted();
    }
}